using System.ServiceModel;
using TimeLineControlNamedPipes.Communication;
using TimeLineDataContract;

namespace TimeLineControlNamedPipes
{
    // Create this class to send a message on a named pipe.
    public class SenderPipe
    {
        public static void SendPowerPointPipeOk(string pipename)
        {
            var ep = new EndpointAddress(
                string.Format("{0}/{1}",
                PipeService.UriPowerPoint,
                pipename));
            var proxy = ChannelFactory<IPipeService>.CreateChannel(new NetNamedPipeBinding(), ep);
            proxy.PipeSendOk();
        }

        public static void SendTimeLineShowSlideRunning(bool running, string pipename)
        {
            var ep = new EndpointAddress(
                string.Format("{0}/{1}",
                PipeService.UriControl,
                pipename));
            var proxy = ChannelFactory<IPipeService>.CreateChannel(new NetNamedPipeBinding(), ep);
            proxy.PipeSlideRunning(running);
        }

        public static void SendTimeLineShowBar(bool show, string pipename)
        {
            var ep = new EndpointAddress(
                string.Format("{0}/{1}",
                PipeService.UriControl,
                pipename));
            var proxy = ChannelFactory<IPipeService>.CreateChannel(new NetNamedPipeBinding(), ep);
            proxy.PipeShowbar(show);
        }

        public static void SendPowerPointShowBar(bool show, string pipename)
        {
            var ep = new EndpointAddress(
                string.Format("{0}/{1}",
                PipeService.UriPowerPoint,
                pipename));
            var proxy = ChannelFactory<IPipeService>.CreateChannel(new NetNamedPipeBinding(), ep);
            proxy.PipeShowbar(show);
        }

        public static void SendTimeLinechangeNamePowePoint(string appName,string pipename)
        {
            var ep = new EndpointAddress(
                string.Format("{0}/{1}",
                PipeService.UriControl,
                pipename));
            var proxy = ChannelFactory<IPipeService>.CreateChannel(new NetNamedPipeBinding(), ep);
            proxy.PipeSendNameApp(appName);
        }

        public static void SendTimeLineSlidesDesk(SlideDeskContract[] messages, string pipename)
        {
            var ep = new EndpointAddress(
                string.Format("{0}/{1}",
                PipeService.UriControl,
                pipename));
            var proxy = ChannelFactory<IPipeService>.CreateChannel(new NetNamedPipeBinding(), ep);
            proxy.PipeSendSlidesDeck(messages);
        }

        public static void SendPowerPointSlidesDesk(string pipename)
        {
            var ep = new EndpointAddress(
                string.Format("{0}/{1}",
                PipeService.UriPowerPoint,
                pipename));
            var proxy = ChannelFactory<IPipeService>.CreateChannel(new NetNamedPipeBinding(), ep);
            proxy.PipeSendSlidesDeck(new SlideDeskContract[]{});
        }

        public static void SendTimeLineCurrentSlide(SlideDeskContract messages, string pipename)
        {
            var ep = new EndpointAddress(
                string.Format("{0}/{1}",
                PipeService.UriControl,
                pipename));
            var proxy = ChannelFactory<IPipeService>.CreateChannel(new NetNamedPipeBinding(), ep);
            proxy.PipeSendCurrentSlide(messages);
        }

        public static void SendPowerPointCurrentSlide(SlideDeskContract messages, string pipename)
        {
            var ep = new EndpointAddress(
                string.Format("{0}/{1}",
                PipeService.UriPowerPoint,
                pipename));
            var proxy = ChannelFactory<IPipeService>.CreateChannel(new NetNamedPipeBinding(), ep);
            proxy.PipeSendCurrentSlide(messages);
        }

    }
}
